package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Strategy extends BaseDomain{

    public static final Integer STATE_COMMEND = 1;
    public static final Integer STATE_NORMAL = 0;
    public static final Integer STATE_DISABLED = -1;

    private Region place;

    private String title;

    private String subTitle;

    private String coverUrl;

    private Integer state;

    public String getStateName(){
        String temp = "普通";
        if (state == STATE_COMMEND) {
            temp = "推荐";
        }else if (state == STATE_DISABLED) {
            temp = "禁用";
        }
        return temp;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        if (place != null) {
            map.put("placeId",place.getId());
            map.put("placeName",place.getName());
        }
        return JSONUtil.toJSONString(map);
    }
}